#!/bin/bash -

# Generate RPM provides automatically for nbdkit packages and filters.
# Copyright (C) 2009-2022 Red Hat Inc.

# To test:
# find /usr/lib64/nbdkit/plugins | ./nbdkit-find-provides VER REL
# find /usr/lib64/nbdkit/filters | ./nbdkit-find-provides VER REL

ver="$1"
rel="$2"

function process_file
{
    if [[ $1 =~ /plugins/nbdkit-.*-plugin ]] ||
       [[ $1 =~ /filters/nbdkit-.*-filter ]]; then
        echo "Provides:" "$(basename $1 .so)" "=" "$ver-$rel"
    fi
}

while read line; do
    process_file "$line"
done
